package com.lzc.service.impl;

import org.apache.log4j.Logger;

import com.lzc.dao.UserDao;
import com.lzc.dao.impl.UserDaoImpl;
import com.lzc.pojo.User;
import com.lzc.service.UserService;





public class UserServiceImpl implements UserService {
	//声明日志对象
		Logger logger = Logger.getLogger(UserServiceImpl.class);
		//声明Dao层对象
		UserDao ud = new UserDaoImpl();
		//用户登录
		@Override
		public User checkUserLoginService(String uname, String pwd) {
			// TODO Auto-generated method stub
			//打印日志
			logger.debug(uname+"发起了登录请求");
			User u = ud.checkLoginDao(uname, pwd);
			//判断
			if (u!=null) {
				logger.debug(uname+"登录成功");
			}else {
				logger.debug(uname+"登录失败");
			}
			
			return u;
		}
		//用户注册
		@Override
		public int userRegService(User u) {
			// TODO Auto-generated method stub
			return ud.userRegDao(u);
		}
		//修改密码
		@Override
		public int userChangePwdService(String newPwd, int uid) {
			// TODO Auto-generated method stub
			logger.debug(uid+"：发起了修改密码请求");
			int index = ud.userChangePwdDao(newPwd,uid);
			if (index>0) {
				logger.debug(uid+"：修改密码成功");
			} else {
				logger.debug(uid+"：修改密码失败");
			}
			
			return index;
		}
		
}
